<? 
	define('IN_SITE', true);
	include ("common.php");

	$ids = isset($_REQUEST['ids'])? $_REQUEST['ids'] : session_id() ;
	$type=isset($_GET["type"]) ? htmlspecialchars($_GET["type"]) : ''; 
	
?>
<html>
<head>
<title>Enquiry - YellowPages.vn</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></meta>
<meta name="description" content="Find business listings in Vietnam with YELLOWPAGES.vn. Search by company's name, type of company, category, products & services, phone, fax, etc."></meta>
<meta name="keywords" content="business directory, Vietnam, yellow pages, yellow page, directory, portal, regional, phonebook, business guides, commercial guides, consumer guides, industrial guides, company guides, product guides, services guides, tour guide, company listings, product listings, services listings, businesses information, companies information, products searches, services searches, classified, company classifieds, products classifieds, services classifieds, company searches, classified ads, classified advertisements,ecommerce"></meta>
<meta name="keyPhrase" content="Business Yellow Pages"></meta>
<meta name="author" CONTENT="Vietnam Yellow Pages Joint Stock Company"></meta>
<meta name="robots" content="index,follow"></meta>

<link type="text/css" rel="stylesheet" href="css/style.css">
<link type="text/css" rel="stylesheet" href="css/link.css">
<link type="text/css" rel="stylesheet" href="css/usercss.css">
<link type="text/css" rel="stylesheet" href="css/css.css">

<style>
	.formborderstyle {BORDER-RIGHT: #fed80b 2px solid; BORDER-LEFT: #fed80b 2px solid}
	.text {FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Arial, Helvetica, sans-serif; TEXT-DECORATION: none}
	body {margin-left: 10px;margin-top: 10px;margin-right: 5px;margin-bottom: 5px;}
</style>
<script language="javascript">lang='<?=$lang?>';</script>
<script language="javascript" src="js/function.js"></script>
<script language="javascript" src="js/method.js"></script>
</head>
<body leftMargin=0 topMargin=0 align="center" marginheight="0" marginwidth="0">
<table width=547 border=0 align="center" cellPadding=0 cellSpacing=0 bgcolor="#ffffb3">
<tr><td>
<table cellSpacing=0 cellPadding=0 width=547 border=0>
  <TBODY>
  <TR>
    <TD><IMG height=76 src="images/enquiry_top_en.gif" width=547></TD></TR></TBODY></table>
<table class="formborderstyle" cellSpacing=1 cellPadding=5 width="547" bgColor="#ffffb3" border="0">
<tr><td>
<?php 
	$template_products_body="template/product_list.tpl";
	$template_contactList="template/contact_list.tpl";
	$template_memContact="template/memContact.tpl";
	$template_guestContact="template/guestContact.tpl";
	
	$base_url 	= 'index.php';
	
	$mode =isset($_GET["mode"]) ? htmlspecialchars($_GET["mode"]) : ''; 

	switch($mode){ 
	  case "send":
		  sendContact();
		  break;
	  case "gsend":
		  SendGuestContact();
		  break;
	  default:
		  viewcontact(); 
		  break; 
	 }  
	 
function viewcontact(){
	global $template, $db,$base_url,$site_base_href,$mode; 
		
	$type=isset($_GET["type"]) ? htmlspecialchars($_GET["type"]) : ''; 
	
	if($type=="addToCard" || $mode=="addToCard"){
		AddToBasket();
		return;
	}
	$ses_login = isset($_SESSION['ses_login']) ? $_SESSION['ses_login'] : '' ;
	if(isset($ses_login["s_user"])){
		memContact();
		return;
	}else{
		guestContact();
		return;
	}	 
}
function SendGuestContact(){
	
	global $db,$template,$site_base_href;
	require_once("class/email.php");
	//Thu nhan bien tu form	
	$txtQuantity=isset($_POST["txtQuantity"]) ? htmlspecialchars($_POST["txtQuantity"]) : ' '; 
	$txtSubject=isset($_POST["txtSubject"]) ? htmlspecialchars($_POST["txtSubject"]) : ' '; 
	$txtMessage=isset($_POST["txtMessage"]) ? htmlspecialchars($_POST["txtMessage"]) : ' ';
	
	$txtFirsName=isset($_POST["txtFirsName"]) ? htmlspecialchars($_POST["txtFirsName"]) : ' '; 
	$txtLastName=isset($_POST["txtLastName"]) ? htmlspecialchars($_POST["txtLastName"]) : ' '; 
	$txtCompany=isset($_POST["txtCompany"]) ? htmlspecialchars($_POST["txtCompany"]) : ' ';
	
	$optContry=isset($_POST["optContry"]) ? intval($_POST["optContry"]) : 0;
	$txtAddress=isset($_POST["txtAddress"]) ? htmlspecialchars($_POST["txtAddress"]) : ' ';
	$txtEmail=isset($_POST["txtEmail"]) ? htmlspecialchars($_POST["txtEmail"]) : ' ';	
 
	$txtContrycode=isset($_POST["txtContrycode"]) ? htmlspecialchars($_POST["txtContrycode"]) : ' ';
	$txtAreacode=isset($_POST["txtAreacode"]) ? htmlspecialchars($_POST["txtAreacode"]) : ' ';
	$txtBussinessPhone=isset($_POST["txtBussinessPhone"]) ? htmlspecialchars($_POST["txtBussinessPhone"]) : ' ';
	$Phone=$txtContrycode." " .$txtAreacode." ".$txtBussinessPhone;
	
	$txtContrycodefax=isset($_POST["txtContrycodefax"]) ? htmlspecialchars($_POST["txtContrycodefax"]) : ' ';
	$txtAreacodefax=isset($_POST["txtAreacodefax"]) ? htmlspecialchars($_POST["txtAreacodefax"]) : ' ';
	$txtBussinessPhonefax=isset($_POST["txtBussinessPhonefax"]) ? htmlspecialchars($_POST["txtBussinessPhonefax"]) : ' ';
	$fax=$txtContrycodefax." ".$txtAreacodefax." ".$txtBussinessPhonefax;
	
	$contactID=isset($_POST["contactID"]) ? intval($_POST["contactID"]) : 0;
	$chkSes=isset($_POST["chkSes"]) ? intval($_POST["chkSes"]) : 0;

	// contact  doi voi giang hang
	if($chkSes){
		$ses_pro=$_SESSION["ses_pro1"];
    }else{
		$ses_pro=$_SESSION["ses_pro"];
	}
	if(is_array($ses_pro)){
		while (list($id,) = each($ses_pro)){
			$id	= intval($id);
			if ($id){
			$sql="select  mEmail,FirstName,vb_member.memID from vb_member inner join vb_memberprofile on vb_member.memID=vb_memberprofile.memID inner join vb_sell_lead on vb_sell_lead.memId=vb_member.memID where vb_sell_lead.lID=".$id;
			if(!$result=$db->sql_query($sql)){			 
			 	message_die("Couldn't run the sql query!","",__LINE__,__FILE__,$sql);
			}	
			$memid=$db->sql_fetchrow($result);	

			$sql="insert into vb_contact (FirstName,LastName,companyName,ContryID,address,email,bphone,bfax,lID,memID,subject,mess,quantity,datepost,proOrder) values ('$txtFirsName','$txtLastName','$txtCompany',$optContry,'$txtAddress','$txtEmail','$Phone','$fax',$id,".$memid['memID'].",'$txtSubject','$txtMessage','$txtQuantity','".date("Y-m-d")."','0')";
			
			if(!$result=$db->sql_query($sql)){			 
				 message_die($sql."Couldn't run the sql query!!","",__LINE__,__FILE__,$sql);
			}	
		
		 $filecontent='Dear '.$memid["FirstName"].',<br>
			You have a new message from a yellowpages.vn member. To view the message logon to the link below:<br>
			<a href="'.$site_base_href.'/userLog.php">'.$site_base_href.'/userLog.php</a><br><br>					
			Kind regards,<br>www.yellowpages.vn Team<br>';					
		 
			$mail= new email();			 
			$mail->to =$memid["mEmail"];
			$mail->toname =$memid["FirstName"];
			$mail->fromname ="VietBig";
			$mail->from = "support@yellowpages.vn";
			$mail->enable_html = true;				
			$mail->subject = "yellowpages.vn";
			$mail->body = $filecontent;		
			$mail->send();		
			}
		}
		
		unset($ses_pro);
		session_unregister("ses_pro1");
		session_unregister("ses_pro");
	}
	
	//contact doi voi san pham
	if($chkSes){
		$ses_pros=$_SESSION["ses_pros1"]; 
	}else{
		$ses_pros=$_SESSION["ses_pros"]; 
	}
	//Goi mail to khach hang
	if(is_array($ses_pros)){
		while (list($id,) = each($ses_pros)){
			$id	= intval($id); 
			if ($id){
			$sql="select mEmail,FirstName,vb_member.memID from vb_member inner join vb_memberprofile on vb_member.memID=vb_memberprofile.memID inner join vb_products on vb_products.memId=vb_member.memID where vb_products.proID=".$id;
			if(!$result=$db->sql_query($sql)){			 
			 	message_die("Couldn't run the sql query!!!3","",__LINE__,__FILE__,$sql);
			}	
			$memid=$db->sql_fetchrow($result);	
			$sql="insert into vb_contact (FirstName,LastName,companyName,ContryID,address,email,bphone,bfax,lID,memID,subject,mess,quantity,datepost,proOrder) values ('$txtFirsName','$txtLastName','$txtCompany',$optContry,'$txtAddress','$txtEmail','$Phone','$fax',$id,".$memid['memID'].",'$txtSubject','$txtMessage','$txtQuantity','".date("Y-m-d")."','1')";

			if(!$result=$db->sql_query($sql)){			 
				 message_die($sql."Couldn't run the sql query!!!4","",__LINE__,__FILE__,$sql);
			}	
		 $filecontent='Dear '.$memid["FirstName"].',<br>
			You have a new message from a YellowPages.vn member. To view the message logon to the link below:<br>
			<a href="'.$site_base_href.'/userLog.php">'.$site_base_href.'</a><br><br>					
			Kind regards,<br> www.yellowpages.vn Team<br><br><br><a href="javascript:window.close();" class="quote">Close</a>';					
	 
		$mail= new email();			 
		$mail->to =$memid["mEmail"];
		$mail->toname =$memid["FirstName"];
		$mail->fromname ="VietBig";
		$mail->from = "support@yellowpages.vn";
		$mail->enable_html = true;				
		$mail->subject = "yellowpages.vn";
		$mail->body = $filecontent;		
		$mail->send();		
			}
		}
		unset($ses_pros);
		session_unregister("ses_pros1");
		session_unregister("ses_pros");
	}
	// contact toi khach hang
	if(!empty($contactID)){	
		$sql="insert into vb_contact (FirstName,LastName,companyName,ContryID,address,email,bphone,bfax,lID,memID,subject,mess,quantity,datepost,proOrder) values ('$txtFirsName','$txtLastName','$txtCompany',$optContry,'$txtAddress','$txtEmail','$Phone','$fax',0,$contactID,'$txtSubject','$txtMessage','$txtQuantity','".date("Y-m-d")."','3')";
		 
	if(!$result=$db->sql_query($sql)){			 
		 message_die("Couldn't run the sql query!!!5","",__LINE__,__FILE__,$sql);
	}	
		
		$sql="select  mEmail,FirstName from vb_member inner join vb_memberprofile on vb_member.memID=vb_memberprofile.memID  where vb_member.memID=".$contactID;
 
			if(!$result=$db->sql_query($sql)){			 
			 	message_die("Couldn't run the sql query!!!","",__LINE__,__FILE__,$sql);
			}	
			$memid=$db->sql_fetchrow($result);	
		 $filecontent='Dear '.$memid["FirstName"].',<br>
			You have a new message from a yellowpages.vn member. To view the message logon to the link below:<br>
			<a href="'.$site_base_href.'/userLog.php">'.$site_base_href.'</a><br><br>					
			Kind regards,<br>www.yellowpages.vn Team<br><br><br><a href="javascript:window.close();" class="quote">Close</a>';					
	
		$mail= new email();			 
		$mail->to =$memid["mEmail"];
		$mail->toname =$memid["FirstName"];
		$mail->fromname ="YellowPages";
		$mail->from = "support@yellowpages.vn";
		$mail->enable_html = true;				
		$mail->subject = "YellowPages.vn";
		$mail->body = $filecontent;		
		$mail->send();		
		
	}	
	echo '<table width="100%"  border="0" cellspacing="0" cellpadding="0">
		  <tr>
			<td height="300" valign="top" class="text-default">	<div align="center" ><br>
			  <br>Thank you! Message Successfully Sent!<br>Thank you for contacting us. We will reply your inquiry as soon as possible.<br><br><br><br><a href="javascript:window.close();">Close</a> </td>
		  </tr>
		</table>';
} 
function sendContact(){
	global $db,$template,$site_base_href;
	
	$txtQuantity=isset($_POST["txtQuantity"]) ? htmlspecialchars($_POST["txtQuantity"]) : ''; 
	$txtSubject=isset($_POST["txtSubject"]) ? htmlspecialchars($_POST["txtSubject"]) : ''; 
	$txtMessage=isset($_POST["txtMessage"]) ? htmlspecialchars($_POST["txtMessage"]) : '';
	$chkSes=isset($_POST["chkSes"]) ? intval($_POST["chkSes"]) : 0 ;
	$contactID=isset($_POST["contactID"]) ? intval($_POST["contactID"]) : 0;
	
	if($chkSes){
		$ses_pro=$_SESSION["ses_pro1"];
		$ses_pros=$_SESSION["ses_pros1"];
	}else{	
		$ses_pro=$_SESSION["ses_pro"];

		$ses_pros=$_SESSION["ses_pros"];
	}	
	
	require_once("class/email.php");		
		 
	if(!empty($contactID)){
		$sql='select s.memID,s.lID,p.FirstName,p.LastName,m.mEmail,p.CompanyName,p.Address,p.countryID,CONCAT(p.contrycode," ",p.areacode," ",BusinessPhone) as bphone,CONCAT(p.faxcontrycode," ",p.faxareacode," ",FaxNumber) as bfax from vb_sell_lead s inner join vb_member m on m.memID=s.memID inner join vb_memberprofile p on m.memID=p.memID where m.memID='.$contactID ." limit 1";
		if(!$result=$db->sql_query($sql)){			 
	 		 message_die("Couldn't run the sql query!!!1","",__LINE__,__FILE__,$sql);
		}	
		$cust_data=$db->sql_fetchrow($result);	
		$db->sql_freeresult($result);	
	
		$sql="insert into vb_contact(FirstName,LastName,companyName,ContryID,address,email,bphone,bfax,lID,memID,subject,mess,quantity,datepost,proOrder) values('".$cust_data["FirstName"]."','".$cust_data["LastName"]."','".$cust_data["CompanyName"]."',".$cust_data["countryID"].",'".$cust_data["Address"]."','".$cust_data["mEmail"]."','".$cust_data["bphone"]."','".$cust_data["bfax"]."',0,".$cust_data["memID"].",'$txtSubject','$txtMessage','$txtQuantity','".date("Y-m-d")."','3')";
 
		if(!$result=$db->sql_query($sql)){			 
	 		 message_die("Couldn't run the sql query!!!2","",__LINE__,__FILE__,$sql);
		}	
		 $filecontent='Dear '.$cust_data["FirstName"].',<br>
					You have a new message from a yellowpages.vn member. To view the message logon to the link below:<br>
					<a href="'.$site_base_href.'/userLog.php">'.$site_base_href.'</a><br><br>					
					Kind regards,<br>www.yellowpages.vn Team<br>';
					
		$mail= new email();	
		 
		$mail->to =$cust_data["mEmail"];
		$mail->toname =$cust_data["FirstName"];
		$mail->fromname ="VietBig";
		$mail->from = "support@yellowpages.vn";
		$mail->enable_html = true;				
		$mail->subject = "yellowpages.vn";
		$mail->body = $filecontent;		
		$mail->send();
		
		echo '<table width="100%"  border="0" cellspacing="0" cellpadding="0">
		  <tr>
			<td height="300" valign="top" class="text-default">	<div align="center" ><br>
			  <br>Thank you! Message Successfully Sent!<br>Thank you for contacting us. We will reply your inquiry as soon as possible.<br><br><br><br><a href="javascript:window.close();">Close</a> </td>
		  </tr>
		</table>';		
		/*echo ' <table width="100%"  border="0" cellspacing="0" cellpadding="0" bgcolor="#ffffb3">
			<tr>
			<td height="300" valign="top" class="text-default">	<div align="center" ><br>
			  <br>Thank you! Message Successfully Sent!<br>Thank you for contacting us. We will reply your inquiry as soon as possible.<br><br><br><a href="javascript:window.close();">Close</a> </td>
			</tr>
			</table>
			'; */
		return;
	}
	
	$sql='select s.memID,s.lID,p.FirstName,p.LastName,m.mEmail,p.CompanyName,	p.Address,p.countryID,CONCAT(p.contrycode," ",p.areacode," ",BusinessPhone) as bphone,CONCAT(p.faxcontrycode," ",p.faxareacode," ",FaxNumber) as bfax  from vb_sell_lead s inner join vb_member m on m.memID=s.memID inner join vb_memberprofile p on m.memID=p.memID	where s.lID=-1';
	
	if(is_array($ses_pro)){
	
		while (list($id,) = each($ses_pro)){
			$id	= intval($id);
			if ($id){
				$sql.=" or s.lID=".$id;
			}
		}
 
		if(!$result=$db->sql_query($sql)){
			message_die("Couldn't run the sql query!!!3","",__LINE__,__FILE__,$sql);
		}	
		$cust_count=$db->sql_numrows($result);
		$cust_data=$db->sql_fetchrowset($result);	
		$db->sql_freeresult($result);	
		
		for($i=0;$i<$cust_count;$i++){
				$sql="insert into vb_contact(FirstName,LastName,companyName,ContryID,address,email,bphone,bfax,lID,memID,subject,mess,quantity,datepost,proOrder) values('".$cust_data[$i]["FirstName"]."','".$cust_data[$i]["LastName"]."','".$cust_data[$i]["CompanyName"]."',".$cust_data[$i]["countryID"].",'".$cust_data[$i]["Address"]."','".$cust_data[$i]["mEmail"]."','".$cust_data[$i]["bphone"]."','".$cust_data[$i]["bfax"]."',".$cust_data[$i]["lID"].",".$cust_data[$i]["memID"].",'$txtSubject','$txtMessage','$txtQuantity','".date("Y-m-d")."','0')";
	
			if(!$result=$db->sql_query($sql)){			 
				 message_die("Couldn't run the sql query!!!4","",__LINE__,__FILE__,$sql);
			}	
			 $filecontent='Dear '.$cust_data[$i]["FirstName"].',<br>
						You have a new message from a yellowpages.vn member. To view the message logon to the link below:<br>
						<a href="'.$site_base_href.'/userLog.php">'.$site_base_href.'</a><br><br>					
						Kind regards,<br>www.yellowpages.vn Team<br>';
			 
			$mail= new email();			 
			$mail->to =$cust_data[$i]["mEmail"];
			$mail->toname =$cust_data[$i]["FirstName"];
			$mail->fromname ="VietBig";
			$mail->from = "support@yellowpages.vn";
			$mail->enable_html = true;				
			$mail->subject = "yellowpages.vn";
			$mail->body = $filecontent;		
			$mail->send();		
		}
		$cust_data=array();
		unset($ses_pro);
		session_unregister("ses_pro");
		session_unregister("ses_pro1");
	}
	
  	if(is_array($ses_pros)){
		$sql='select s.memID,s.proID,p.FirstName,p.LastName,m.mEmail,p.CompanyName,	p.Address,p.countryID,CONCAT(p.contrycode," ",p.areacode," ",BusinessPhone) as bphone,CONCAT(p.faxcontrycode," ",p.faxareacode," ",FaxNumber) as bfax  from vb_products s inner join vb_member m on m.memID=s.memID inner join vb_memberprofile p on m.memID=p.memID where s.proID=-1';
		while (list($id,) = each($ses_pros)){
			$id	= intval($id);
			if ($id){
				$sql.=" or s.proID=".$id;
			}
		}
 
		if(!$result=$db->sql_query($sql)){
		  message_die("Couldn't run the sql query!!!5","",__LINE__,__FILE__,$sql);
		}	
		$cust_count=$db->sql_numrows($result);
		$cust_data=$db->sql_fetchrowset($result);	
		$db->sql_freeresult($result);	
	
		for($i=0;$i<$cust_count;$i++){
				$sql="insert into vb_contact(FirstName,LastName,companyName,ContryID,address,email,bphone,bfax,lID,memID,subject,mess,quantity,datepost,proOrder) values(
				'".$cust_data[$i]["FirstName"]."','".$cust_data[$i]["LastName"]."','".$cust_data[$i]["CompanyName"]."',".
				$cust_data[$i]["countryID"].",'".$cust_data[$i]["Address"]."','".$cust_data[$i]["mEmail"]."','".
				$cust_data[$i]["bphone"]."','".$cust_data[$i]["bfax"]."',".$cust_data[$i]["proID"].",".$cust_data[$i]["memID"].",'$txtSubject','$txtMessage','$txtQuantity','".date("Y-m-d")."','1')";
	 
			if(!$result=$db->sql_query($sql)){			 
				 message_die("Couldn't run the sql query!!!6","",__LINE__,__FILE__,$sql);
			}	
					 $filecontent='Dear '.$cust_data[$i]["FirstName"].',<br>
						You have a new message from a yellowpages.vn member. To view the message logon to the link below:<br>
						<a href="'.$site_base_href.'/userLog.php">'.$site_base_href.'</a><br><br>					
						Kind regards,<br>
						www.yellowpages.vn Team<br>';
						
			 
			$mail= new email();			 
			$mail->to =$cust_data[$i]["mEmail"];
			$mail->toname =$cust_data[$i]["FirstName"];
			$mail->fromname ="VietBig";
			$mail->from = "support@yellowpages.vn";
			$mail->enable_html = true;				
			$mail->subject = "yellowpages.vn";
			$mail->body = $filecontent;		
			$mail->send();	
		}
		$cust_data=array();
		unset($ses_pros);
		session_unregister("ses_pros");
		session_unregister("ses_pros1");
		}			
 	
	echo '<table width="100%"  border="0" cellspacing="0" cellpadding="0">
		  <tr>
			<td height="300" valign="top" class="text-default">	<div align="center" ><br>
			  <br>Thank you! Message Successfully Sent!<br>Thank you for contacting us. We will reply your inquiry as soon as possible.<br><br><br><br><a href="javascript:window.close();">Close</a> </td>
		  </tr>
		</table>';
	/*echo ' <table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="300" valign="top" class="quote">	<div align="center" ><br>
      <br>Thank you! Message Successfully Sent!<br>Thank you for contacting us. We will reply your inquiry as soon as possible.<br><br><br><br><br><br><a href="javascript:window.close();" class="quote">Close</a>  </td>
  </tr>
</table>
';	*/
}
//****************************************
function guestContact(){
	global $template,$template_guestContact,$base_url,$site_base_href,$ids ;
	$chkcontactonly	= isset($_GET["chkSes"]) ? intval($_GET["chkSes"]) : 0;	
	 getContry();
	 addCart();

	$i=rand(4,5);
	$id_random = '' ;
	for($j=0;$j<$i;$j++){
		$id_random .= chr(rand(65,90));
	}
	
	if($chkcontactonly){
		$ses_pro = isset($_SESSION["ses_pro1"])? $_SESSION["ses_pro1"] : '' ;
		$ses_pros = isset($_SESSION["ses_pros1"])? $_SESSION["ses_pros1"] : '' ;
	}else{
		$ses_pro = isset($_SESSION["ses_pro"]) ? $_SESSION["ses_pro"] : '' ;
		$ses_pros = isset($_SESSION["ses_pros"]) ? $_SESSION["ses_pros"] : '' ;
	}
	$ses = 0 ;
	if(is_array($ses_pro)){	
	 	$ses = count($ses_pro);
	}
	if(is_array($ses_pros)){	
	 	$ses += count($ses_pros);
	}

	if($ses>1){
		$comp='<a href="javascript:void(0)" onClick="displayDiv()">'.$ses.' Company </a>';
	}else{
		$comp=getCompany();
	}

	$template->assign_vars(array(
		'company' 	=>$comp,
		'ranima' 	=> base64_encode(base64_encode($id_random)),
		'hdranima' 	=>$id_random,
		'con_company' =>getCompany(),
		'getImage' 	=>$site_base_href.'/',
		'chkSes'	=>	$chkcontactonly,
		's_action'	=> "feedback.php?mode=gsend"	
		//'s_action'	=>$site_base_href."/".$base_url."?ids=".$ids."&lang=us&/contact/gsend/"		
	));
	
	$template->set_filenames(array(
		'body' =>$template_guestContact
	));
	$template->pparse('body');		
}
function memContact(){
	global $template,$template_memContact,$site_base_href,$base_url;
	
	addCart();
	$chkcontactonly	= isset($_GET["chkSes"]) ? intval($_GET["chkSes"]) : 0;	
	if($chkcontactonly){
		$ses_pro=$_SESSION["ses_pro1"];
		$ses_pros=$_SESSION["ses_pros1"];
	}else{
		$ses_pro=$_SESSION["ses_pro"];
		$ses_pros=$_SESSION["ses_pros"];
	}
	if(is_array($ses_pro)){	
	 	$ses=count($ses_pro);
	}
	if(is_array($ses_pros)){	
	 	$ses+=count($ses_pros);
	}
	
	if($ses>1){
		$comp='<a href="javascript:void(0)" onClick="displayDiv()">'.$ses.' Company </a>';
	}else{
		$comp=getCompany();
	}
	$template->assign_vars(array(
		'company' =>$comp,
		'con_company' =>getCompany(),
		'chkSes'=>	$chkcontactonly,
		's_action'	=> "feedback.php?mode=send"	
		//'s_action'	=>$site_base_href."/".$base_url."?/contact/send/"		
	));
	
	$template->set_filenames(array(
		'body' =>$template_memContact
	));
	$template->pparse('body');		
	unset($ses_pros);

}
function AddToBasket(){
	global $db,$template_contactList,$site_base_href,$base_url,$template;

	addCart();
	$ses_pro=$_SESSION["ses_pro"];
	$ses_pros=$_SESSION["ses_pros"];
	if(count($ses_pro)<1 && count($ses_pros)<1 ){
		redirect($site_base_href."/Inquiry.php");
	}
	if($ses_pro){
	$sql='  select s.memID,s.lID,s.proID,s.subject,p.CompanyName,p.countryID from vb_sell_lead s inner join vb_member m on m.memID=s.memID inner join vb_memberprofile p on m.memID=p.memID
	where s.lID=-1';
	if(is_array($ses_pro)){
		while (list($id,) = each($ses_pro)){
			$id	= intval($id);
			if ($id){
				$sql.=" or s.lID=".$id;
			}
		}
	if(!$result=$db->sql_query($sql)){
	  message_die("Couldn't run the sql query!!!","",__LINE__,__FILE__,$sql);
	}	
	$cust_count=$db->sql_numrows($result);
	$cust_data=$db->sql_fetchrowset($result);	
	$db->sql_freeresult($result);	
	
	for($i=0;$i<$cust_count;$i++){
			$template->assign_block_vars("ContactList", array(							
				'subject' =>$cust_data[$i]["subject"],
				'url' => $site_base_href.'/supplier.php?supplier='.$cust_data[$i]["memID"].'&act=vleads&mode=leadsdetail&lid='.$cust_data[$i]["lID"],
				'company'	=>$cust_data[$i]["CompanyName"],
				'country' =>getContry($cust_data[$i]["countryID"]),				
				'CHECKBOX'	 => '<input type="Checkbox" name="proid['.$cust_data[$i]["lID"].']" value="'. $cust_data[$i]["proID"] .'" checked />'
			));
		}
	}
	}
	$ses_pros=$_SESSION["ses_pros"];
	if($ses_pros){
	$sql='select s.memID,s.proID,s.ProductName,s.catID,p.CompanyName,p.countryID from vb_products s inner join vb_member m on m.memID=s.memID inner join vb_memberprofile p on m.memID=p.memID
	where s.proID=-1';
	if(is_array($ses_pros)){
	
		while (list($id,) = each($ses_pros)){
			$id	= intval($id);
			if ($id){
				$sql.=" or s.proID=".$id;
			}
		}
		 
	if(!$result=$db->sql_query($sql)){
	  message_die("Couldn't run the sql query!!!","",__LINE__,__FILE__,$sql);
	}	
	$cust_count=$db->sql_numrows($result);
	$cust_data=$db->sql_fetchrowset($result);	
	$db->sql_freeresult($result);	
	
	for($i=0;$i<$cust_count;$i++){
			$template->assign_block_vars("ContactList", array(							
				'subject' =>$cust_data[$i]["ProductName"],
				'url' => $site_base_href.'/supplier.php?supplier='.$cust_data[$i]["memID"].'&act=products&mode=productDetail&pid='.$cust_data[$i]["proID"].'&catID='.$cust_data[$i]["catID"],
				'company'	=>$cust_data[$i]["CompanyName"],
				'country' =>getContry($cust_data[$i]["countryID"]),				
				'CHECKBOX'	 => '<input type="Checkbox" name="proidP['.$cust_data[$i]["proID"].']" value="1" checked />'
			));
		}
	}
	}
	$template->assign_vars(array(	
		'S_ACTION' =>$site_base_href.'/index.php?/contact',
		'c_delete' =>$site_base_href.'/index.php?/contact/delete'
	));
	
	$template->set_filenames(array(
		'body' =>$template_contactList
		));
	$template->pparse('body');		
}
function getCompany(){
	global $db;
	
	$chkcontactonly	= isset($_REQUEST["chkSes"]) ? intval($_REQUEST["chkSes"]) : 0;	
	if($chkcontactonly){		
		$ses_pros=$_SESSION["ses_pros1"];
	}else{
		$ses_pros=$_SESSION["ses_pros"];
	}
	
	$comName='';

	$sql='select  m.CompanyName,p.proID from vb_memberprofile m inner join vb_products p on m.memID=p.memID where p.proID=-1';
		while (list(, $id) = each($ses_pros)){
			$id	= intval($id);
			if ($id){
				$sql.=" or p.proID=".$id;
			}
		}
		 
 
	if(!$result=$db->sql_query($sql)){
	  message_die("Couldn't run the sql query!!!","",__LINE__,__FILE__,$sql);
	}
	$comp=array();
	$cust_count=$db->sql_numrows($result);
	$cust_data=$db->sql_fetchrowset($result);	
	$db->sql_freeresult($result);	
	for($i=0;$i<$cust_count;$i++){
		$comp[$cust_data[$i]["proID"]]=$cust_data[$i]["CompanyName"];
	} 
	$cust_data=array();
	 if($chkcontactonly){		
		$ses_pros=$_SESSION["ses_pros1"];
	}else{		
		$ses_pros=$_SESSION["ses_pros"];
	}
		while (list(, $id) = each($ses_pros)){
			$id	= intval($id);			
			 
			if ($id){
				$comName.=$comp[$id]."<br>";
				
			}
	}
	if($chkcontactonly){
		$ses_pro = isset($_SESSION["ses_pro1"]) ? $_SESSION["ses_pro1"] : '' ;		 
	}else{
		$ses_pro = isset($_SESSION["ses_pro"]) ? $_SESSION["ses_pro"] : '' ;
		 
	}
	if(!empty($ses_pro)){
	$sql='select  m.CompanyName,p.proID from vb_memberprofile m inner join vb_products p on m.memID=p.memID where p.proID=-1';
		while (list(, $id) = each($ses_pro)){
			$id	= intval($id);
			if ($id){
				$sql.=" or p.proID=".$id;
			}
		}
 	 
	if(!$result=$db->sql_query($sql)){
	  message_die("Couldn't run the sql query!!!","",__LINE__,__FILE__,$sql);
	}
	$comp=array();
	$cust_count=$db->sql_numrows($result);
	$cust_data=$db->sql_fetchrowset($result);	
	$db->sql_freeresult($result);	
	for($i=0;$i<$cust_count;$i++){
		$comp[$cust_data[$i]["proID"]]=$cust_data[$i]["CompanyName"];
	}
	$cust_data=array();
	
	if($chkcontactonly){
		$ses_pro = isset($_SESSION["ses_pro1"])? $_SESSION["ses_pro1"] : '' ;		 
	}else{
		$ses_pro= isset($_SESSION["ses_pro"]) ? $_SESSION["ses_pro"] :'' ;		 
	}
	while (list(,$id) = each($ses_pro)){
		$id	= intval($id);			 
		if ($id){
			$comName.=$comp[$id]."<br>";
		}
	 }
	}	 
	
	return $comName;
}
function addCart(){	
	$proid			= isset($_GET["proid"]) ? $_GET["proid"] : '';
	$chkcontactonly	= isset($_GET["chkSes"]) ? intval($_GET["chkSes"]) : 0;	
	
	$proid = explode(",",$proid) ;
	$idpro = krsort($proid) ;
	
	if ( !empty($proid) ){
		if ( !is_array($proid) ){
			$pro_id[0]	= $proid;
		}else{
			$pro_id	= $proid;
		}
		unset($proid);
		
		if(!isset($_SESSION["ses_pros"])){
			session_register("ses_pros");		
		}	
		
		$ses_pros=$chkcontactonly ? '' :  $_SESSION["ses_pros"];
		
		if(count($ses_pros)>38){
			return;
		}
		while (list($id, $value) = each($pro_id)){
			$id	= intval($value);
			if ($id){
				$ses_pros[$id]=$value;					 
			}
		}	
		if($chkcontactonly){
	 		$_SESSION['ses_pros1']=$ses_pros;	
		}else{
			$_SESSION['ses_pros']=$ses_pros;	
		}
	}
	return;
}
?>
</td></tr>
</table>
	<table height="76" cellSpacing="0" cellPadding="0" width="547" border="0" id="table4">
	<tr>
		<td vAlign="center" align="middle" background="images/enquiry_footer_en.gif" height="76" class="text">
		  <div align="center"><span class="text">©2001 - 2007 YELLOW PAGES JSC. All rights reserved.<br>
	      HCMC : (84-8) 404 3838 - Hanoi : (84-4) 719 2302 - Binh Duong : (84-650) 759 439</span></div></td>
	</tr>
</table>
</td></tr></table>
</body>
</html>